<template>
  <el-dialog
    append-to-body
    :title="info"
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    align="left"
    v-loading="currLoading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.8)"
    top="30px"
    width="1200px">
    <supplier-order-apply-detail-box :reload-detail="reloadDetail" v-if="detail.id>0 && dialogVisible" :detail="detail" />
  </el-dialog>
</template>

<script>
import ProductItem from '../Common/ProductItem'
import OrderApplyDetailBox from '../Common/OrderApplyDetailBox'
import SupplierOrderApplyDetailBox from '../Common/SupplierOrderApplyDetailBox'

export default {
  name: 'SupplierOrderApplyDialog',
  components: {SupplierOrderApplyDetailBox, ProductItem},
  props: {
    successFunction: Function
  },
  data: function () {
    return {
      info: '供货单-退换货-详情',
      dialogVisible: false,
      currLoading: false,
      detail: {
        id: 0
      }
    }
  },
  destroyed () {
    this.detail.id=0
  },
  mounted () {

  },
  methods: {
    reloadDetail:function () {
      let $this=this
      var id=$this.detail.id
      $this.detail.id=0
      setTimeout(function () {
        $this.getDetail(id)
        if (typeof $this.$props.successFunction){
          $this.$props.successFunction()
        }
      },500)
    },
    open: function (id) {
      // this.detail = detail
      this.getDetail(id)
      this.$forceUpdate()
    },
    hide: function () {
      this.detail.id = 0
      this.dialogVisible = false
      this.$forceUpdate()
    },
    getDetail(id){
      let $this=this
      $this.MyRequest($this.ApiDoNameSupplier + 'SupplierOrderApply/getDetail', {id}, function (data) {
        $this.detail = data
        $this.dialogVisible = true
        $this.$forceUpdate()
      }, function (res) {
        $this.$message.error(res.message)
        $this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
